package thread;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Vector;
import java.util.concurrent.CountDownLatch;

/**
 * Created by Zhou_Bing on 2019/4/30.
 */
public class Demo3 {

    public static void main(String[] args){


        for(int total=1;total<9999;total++){
            Vector<Map<String,Object>> vector = new Vector<>();
            Vector<Map<String,Object>> tempVector = new Vector<>();
            for(int i=0;i<total;i++){
                vector.add(new HashMap<>());
            }

            int size = 10;
            final CountDownLatch downLatch = new CountDownLatch(size);
            int i=0;
            for(i=0;i<size;i++){
                int finalI = i;
                Thread thread = new Thread(new Runnable() {
                    @Override
                    public void run() {
                        for (int j = finalI; j<vector.size(); j+=size) {
                            tempVector.add(vector.get(j));
                        }
                        downLatch.countDown();
                    }
                });
                thread.start();
            }
            try {
                downLatch.await();
                if(total!=tempVector.size()){
                    System.out.println(total+"~~~~~~"+tempVector.size());
                }

            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }


    }
}
